Load the necessary libraries
pandocBoth LaTeX and HTML are markup languages. They both have standardized short-hand syntax to specify how content should be styled and formatted. Markdown is another markup language with its own specific syntax, yet is far simpler and less verbose than either LaTeX or HTML. The goal of markup languages is to provide simple styling rules and syntax so as to allow the author to concentrate on the content. To this end, the highly simplified syntax of the markdown language makes it one of the briefest and content rich formats. Unlike, many other markup languages (such as LaTeX and HTML), carriage returns and spaces form an important part of the language structure and thus influence the formatting of the final document.
To gain an appreciation of some of the simple styling rules of a markdown document, consider the following:
---
title: Example markdown
author: D. Author
date: 16-06-2020
---
This is the title
=====================
## Section 1
A paragraph of text containing a word that is **emphasised** or ~~strikethrough~~.
Followed by an unordered list:
- item 1
- item 2
Or perhaps an enumerated list:
1. item 1
2. item 2
### Subsection 1.1
There might be a [link](https://www.markdownguide.org/) or even a table:
+-----------+---------+-----------------------+
| Item | Example | Description |
+===========+=========+=======================+
| numeric | 12.34 | floating point number |
+-----------+---------+-----------------------+
| character | 'Site' | words |
+-----------+---------+-----------------------+
| ... | | |
+-----------+---------+-----------------------+
Even in plain text, the general formatting is obvious. This simplicity also makes markdown an ideal language for acting as a base source from which other formats (such as PDF, HTML, Presentations, Ebooks) can be created as well as a sort of conduit language through which other formats are converted.
Pandoc is a universal document converter that converts between one markup language and another. Specifically, Pandoc can read markdown and subsets of the following formats:
Pandoc can write the following formats:
By way of example, the above markdown can be rendered into multiple popular formats via pandoc.
Many of the above markup languages feature extensive definitions for styling and formatting rules that do not have direct equivalents within other languages. For example, Cascading Style Sheets and Javascript within HTML provide advanced styling and dynamic presentation of content that cannot be easily translated into other languages. Similarly, there are many macros available for LaTeX that enhance the styling and formatting of content relevant to PDF. Consequently, not all of the more advanced features of each of the languages are supported by Pandoc for conversion.
Pandoc fully supports markdown as an input language, making markdown a popular base language to create content from which other formats can be generated. For example, contents authored in markdown can then be converted into PDF, HTML, HTML presentations, eBooks and others. There are currently numerous dialects of the markdown language. Pandoc has its own enhanced dialect of markdown which includes syntax for bibliographies and citations, footnotes, code blocks, tables, enhanced lists, tables of contents, embedded LaTeX math.
This tutorial will focus on markdown as a base source language from which PDF, HTML, presentations and eBooks are created. As a result, the tutorial will focus on Pandoc’s enhanced markdown. That said, from now on, we will not use pandoc directly - rather we will employ specific R functions that engage with pandoc as part of their overall processing.
Rather than introduce the structural elements of markdown and the intricacies of the pandoc tool in abstract terms, the main features will be The pandoc engine described and demonstrated in an R context with Rmarkdown.
You may have noticed in the example above that at the top of the
markdown there were a block of lines starting with three hypens
(---) and ending with three hyphens (---).
When processed via pandoc, these lines define the document’s meta data
(such as the title, author and creation date).
The meta data are a set of key value pairs in YAML
format. The list of useful metadata depends on the intended output.
The following rules can be applied to yield different outcomes:
The three fields must be in order of title, author(s), date with each on a separate line
When omitting a field, the field must be left as a line just
containing the % character
Multiple authors can be defined by either:
; (semicolon)
character---
title: This is the title
author:
- name D. Author
- name D. Other
date: 14-02-2013
---
In addition to the above metadata fields, the YAML header provides a mechanism for storing processing preferences. For example, output dependent options can be specified by indenting each of the options under the output format (the following example indicates that html documents should have a table of contents.
---
title: This is the title
author: D. Author
date: 14-02-2013
output:
html_document:
toc: yes
---
Note, YAML formatting is very
particular. Indentation must be via spaces (not tabs).
Since most of the metadata fields are specific to output behaviours, we will illustrate other fields when describing the associated outputs.
Brief changes to font styles within a block of text can be effective
at emphasizing or applying different meanings to characters.
Common text modifier styles are: italic, bold
and strikethrough.
| Markdown | Result |
|---|---|
| *Italic text* or _Italic text_ | Italic text |
| **Bold text** or __Bold text__ | Bold text |
| ~~Strikethrough~~ | |
| `Monospace font` | Monospaced font |
| superscript^2^ | superscript2 |
| subscript~2~ | subscript2 |
If the content to be raised or lowered (for super- and sub- scripts) contains spaces, then they must be escaped by proceeding the space with a  character. For example, Effect~Oxygen\ concentration~ equates to EffectOxygen concentration.
Note, underlined text is not defined in any dialect of markdown (including pandoc markdown) as the developers believe that the underline style is a relic of the days of typewriters when there where few alternatives for emphasizing words. Furthermore, underlining of regular words within a sentence tends to break the aesthetic spacing of lines.
Horizontal lines are indicated by a row of three or more
*, - or _ characters (optionally
separated by spaces) with a blank row either side.
---
The rate of oxygen consumption (O~2~ per min^-1^.mg^2^) ...
Effect~Oxygen\ concentration~
Markdown (*.md)
---
title: Example markdown
author: D. Author
date: 16-06-2020
---
This is the title
=====================
A paragraph of text containing a word that is **emphasised**, ~~strikethrough~~
and `Monospace`.
___
The rate of oxygen consumption (O~2~ per min^-1^.mg^2^)
Effect~Oxygen\ concentration~
***
Pandoc markdown supports two heading formats (pandoc markdown headings must be proceeded by a blank line):
Setext-style headings. Level 1 headings are specified by
underlining the heading with a row of = characters and
level 2 headings are specified by underlining with a row of
- characters.
Setext-style headings only support level 1 and level 2 headings.
Section 1
===========
Subsection
------------
### Subsubsection
# Section 2
## Subsection
### Subsection
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
Section 1
============
Subsection
-----------
Section 2
===========
# characters followed by the heading text.Section 1
===========
Subsection
------------
### Subsubsection
# Section 2
## Subsection
### Subsection
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
## Subsection
### Subsubsection
# Section 2
A table of contents can be included by issuing the --toc
command line switch to pandoc. For some output formats
(such as HTML), a block of links to section headings is created, whilst
for others (such as LaTeX), an instruction
(\tableofcontentsfor the external driver to create the
table of contents is generated.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
## Subsection
### Subsubsection
# Section 2
Normal text
> This is a block quotation. Block quotations are specified by
> proceeding each line with a > character. The quotation block
> will be indented.
>
> To have paragraphs in block quotations, separate paragraphs
> with a line containing only the block quotation mark character.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
> This is a block quotation. Block quotations are specified by
> proceeding each line with a > character. The quotation block
> will be indented.
>
> To have paragraphs in block quotations, separate paragraphs
> with a line containing only the block quotation mark character.
Block quotations in pandoc markdown follows email conventions - that
is, each line is proceeded by a > character.
Verbatim blocks are typically used to represent blocks of code syntax. The text within the verbatim block is rendered literally as it is typed (retaining all spaces and line breaks) and in monoscript font (typically courier). In pandoc markdown, verbatim text blocks are specified by indenting a block of text by either four spaces or a tab character. Within verbatim text, regular pandoc markdown formatting rules (due to spaces etc) are ignored.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
a = rnorm(10,5,2)
for (i in 1:10) {
print(a[1])
}
Alternatively, verbatim blocks can be specified without indentation
if the text block is surrounded by a row of three or more ~
characters. This format is often referred to as fenced
code.
Normal text
~~~~
a = rnorm(10,5,2)
for (i in 1:10) {
print(a[1])
}
~~~~
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
~~~
a = rnorm(10,5,2)
for (i in 1:10) {
print(a[1])
}
~~~
There are three basic list environments available within pandoc markdown:
A bullet list item begins with either a *,
+ or - character followed by a single space.
Bullets can also be indented.
Bullet list
* This is the first bullet item
* This is the second.
To indent this sentence on the next line,
the previous line ended in two spaces and
this sentence is indented by four spaces.
* This is the third item
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
* This is the first bullet item
* This is the second.
To indent this sentence on the next line,
the previous line ended in two spaces and
this sentence is indented by four spaces.
* This is the third item
An ordered list item begins with a number followed by a space. The list enumerator can be a decimal number or a roman numeral. In addition to the enumerator, other formatting characters can be used to further define the format of the list numbering.
Ordered list
1. This is the first numbered item.
2. This is the second.
1. This is the third item. Note that the number I supplied is ignored
(i) This is list with roman numeral enumerators
(ii) Another item
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
1. This is the first numbered item.
2. This is the second.
1. This is the third item. Note that the number I supplied is ignored
# Section 2
(i) This is list with roman numeral enumerators
(ii) Another item
Definition list
Term 1
: This is the definition of this term
This is a phrase
: This is the definition of the phrase
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Term 1
: This is the definition of this term
This is a phrase
: This is the definition of the phrase
To include multiple paragraphs (or other blocked content) within a list item or nested lists, the content must be indented by four or more spaces from the main list item.
Nested lists
1. This is the first numbered item.
2. This is the second.
i) this is a sub-point
ii) and another sub-point
1. This is the third item. Note that the number I supplied is ignored
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
1. This is the first numbered item.
2. This is the second.
i) this is a sub-point
ii) and another sub-point
1. This is the third item. Note that the number I supplied is ignored
Normally, pandoc considers a list as complete when a blank line is followed by non-indented text (as markdown does not have starting and ending tags). However, if you wish to place indented text directly after a list, it is necessary to provide an explicit indication that the list is complete. This is done with the <!– end of list –> marker.
Similarly, if you wish to place one list directly following on from another list, a <!– –> marker must be used between the two lists so as to explicitly separate them.
1. This is the first numbered item.
2. This is the second.
1. This is the third item. Note that the number I supplied is ignored
<-- --!>
1. Another list.
2. With more points
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
1. This is the first numbered item.
2. This is the second.
1. This is the third item. Note that the number I supplied is ignored
<!-- -->
1. Another list.
2. With more points
As markdown is a very minimalist markup language that aims to be reasonably well formatted even read as plain text, table formatting must be defined by layout features that have meaning in plain text.
Table captions can be provided by including a paragraph that begins
with either Table: or just :. Everything prior
to the : will be stripped off during processing.
The number of columns as well as column alignment are determined by the relative positions of the table headings and dashed row underneath:
The table must finish in either a blank line or a row of dashes mirroring those below the header followed by a blank row.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Table: A description of the table
Column A Column B Column C
--------- ---------- ---------
Category 1 High 100.00
Category 2 High 80.50
--------- ---------- ---------
Note simple tables do not render well in Libre
Office. The DOCX thumbnail presented below is generated by converting
the DOCX to a png image using unoconv. As this is a command
line tool that is part of the Libre Office family, the resulting
thumbnail will not render the table correctly. The actual DOCx will
nevertheless render fine within either Microsoft Word or WPS Office.
Simple tables can be extended to allow cell contents to span multiple lines. This imposes the following additional layout requirements:
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Table: A description of the table
--------------------------------
Column A Column B Column
C
--------- ---------- ---------
Category 1 High 100.00
High 95.00
Category 2 High 80.50
High 82.50
--------------------------------
Grid tables have a little more adornment in that they use characters to mark all the cell boundaries. However, by explicitly defining the bounds of a cell, grid tables permit more complex cell contents. A grid table for example, can contain a list or a code block etc.
Cell corners are marked by + characters and the table
header and main body are separated by a row of =
characters.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Table: A description of the table
+---------------+---------------+--------------------+
| Fruit | Price | Advantages |
+===============+===============+====================+
| Bananas | $1.34 | - built-in wrapper |
| | | - bright color |
+---------------+---------------+--------------------+
| Oranges | $2.10 | - cures scurvy |
| | | - tasty |
+---------------+---------------+--------------------+
Table: Another table
+-----------+----------+-----------+
|Column A |Column B | Column C|
+===========+==========+===========+
|Category 1 |100.00 | - point A |
| | | - point B |
+-----------+----------+-----------+
|Category 2 | 85.00 | - point C |
| | | - point D |
+-----------+----------+-----------+
Finally, there are also pipe tables. These are somewhat similar to
grid tables in requiring a little more explicit specification of cell
boundaries, however, unlike grid tables, they have a means to configure
column alignment. Cell alignment is specified via the use of
: characters (see example below).. Nor is it necessary to
indicate cell corners.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Table: A description of the table
| Default | left | Center | Right |
|---------|:------|:------:|-------:|
| High | Cat 1 | A | 100.00 |
| High | Cat 2 | B | 85.50 |
| Low | Cat 3 | C | 80.00 |
Note pipe tables do not render well in Libre Office.
The DOCX thumbnail presented below is generated by converting the DOCX
to a png image using unoconv. As this is a command line
tool that is part of the Libre Office family, the resulting thumbnail
will not render the table correctly. The actual DOCx will nevertheless
render fine within either Microsoft Word or WPS Office.
Images are not displayed in plain text (obviously). However, an image
link in pandoc markdown will insert the image into the various
derivative document types (if appropriate), Image links are defined in a
similar manner to other links, yet preceded immediately by a
! character.

#OR
![label]
[label]: filename

Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
Include the JPEG figure
{width=50%}
And a PNG figure
{width=60%}
Markdown leverages TeX math processing. Whilst this does technically break the rules that promote source documents that are readable in text only mode, the payoff is that math is rendered nicely in the various derivative documents (such as pdf or html). In fact, math are passed straight through to the derivative document allowing that document (or is reader) to handle TeX math as appropriate.
Inline math is defined as anything within a pair of $
characters and for math in its own environment (paragraph), use a pair
of $$ characters.
The formula, $y=mx+c$, is displayed inline.
Some symbols and equations (such as
$\sum{x}$ or $\frac{1}{2}$) are rescaled
to prevent disruptions to the regular
line spacing.
For more voluminous equations (such as
$\sum{\frac{(\mu - \bar{x})^2}{n-1}}$),
some line spacing disruptions are unavoidable.
Math should then be displayed in display mode.
$$\sum{\frac{(\mu - \bar{x})^2}{n-1}}$$
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Section 1
The formula, $y=mx+c$, is displayed inline.
Some symbols and equations (such as
$\sum{x}$ or $\frac{1}{2}$) are rescaled
to prevent disruptions to the regular
line spacing.
For more voluminous equations (such as
$\sum{\frac{(\mu - \bar{x})^2}{n-1}}$),
some line spacing disruptions are unavoidable.
Math should then be displayed in displayed mode.
$$\sum{\frac{(\mu - \bar{x})^2}{n-1}}$$
Note not all math are rendered correctly in Libre
Office. The DOCX thumbnail presented below is generated by converting
the DOCX to a png image using unoconv. As this is a command
line tool that is part of the Libre Office family, the resulting
thumbnail will not render some of the equations correctly. The actual
DOCx will nevertheless render fine within either Microsoft Word or WPS
Office.
Links are the linking of information and content between different parts of a document or even between documents. Links provide clickable links to internal or external content.
Internal links make use of the section identifiers that are automatically generated. That is, section headings are automatically defined as labels for referencing. Therefore, to reference (link to) a section simply involves using the target section header as a reference label in the following
[in text label](#Reference label)
The in text label is a word or phrase that should appear
as the link in the text, and reference label is the title
of the section you wish to link to. **Note, there should not be any
spaces between the square braces and the brackets.
Arbitrary links to other internal items such as figures and tables can also be defined
To illustrate, we will define links to a section heading
(#sec), table (tbl) and figure
(fig).
# Introduction {#sec:Intro}
# Section 2
See the [introduction](#sec:Intro).
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Introduction
A simple reference to the [methods section](#Methods).
# Methods
A link to [the table][tbl]
Table: A description of the table
+---------------+---------------+--------------------+
| Fruit | Price | Advantages |
+===============+===============+====================+
| Bananas | $1.34 | - built-in wrapper |
| | | - bright color |
+---------------+---------------+--------------------+
| Oranges | $2.10 | - cures scurvy |
| | | - tasty |
+---------------+---------------+--------------------+
[tbl]: #table1
Linking to external documents follows a similar format:
[in text label](Reference label)
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
Goto the [Google search engine](http://www.google.com)
You can also use the following format:
Goto the [DuckDuckGo].
[DuckDuckGO]: http://www.duckduckgo.com "The DuckDuckGo search engine"
In addition to the above, there is a pandoc filter to
use cross referencing.
We can use pandoc filters to use more sophisticated
cross referencing. This requires adding the pandoc-crossref
and pandoc-citeproc filters and the
--number-sections extensions.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
---
# Introduction {#sec:intro}
{#fig:fig1 width=30%}
A reference to [table @tbl:tab1], [figure @fig:fig1] and [equation @eq:equation1],
([see section @sec:intro]) or even [tables @tbl:tab1] [--@tbl:tab2].
$$ y \sim \beta_0 + \beta_1 X $$ {#eq:equation1}
Table: A description of the table {#tbl:tab1}
+---------------+---------------+--------------------+
| Fruit | Price | Advantages |
+===============+===============+====================+
| Bananas | $1.34 | - built-in wrapper |
| | | - bright color |
+---------------+---------------+--------------------+
Table: Another table {#tbl:tab2}
+-----------+----------+-----------+
|Column A |Column B | Column C|
+===========+==========+===========+
|Category 1 |100.00 | - point A |
+-----------+----------+-----------+
It is always important to cite the original source of an idea or finding, and an analysis document is no exception. It is often and the statistical development stage that methodological references are consulted. It is vital that any used sources are documented - particularly before they are misplaced or forgotten.
Pandoc can incorporate citations from any of the following formats:
BibTeX (.bib), Copac (.copac), CSL JSON
(.json), CSL YAML (.yaml), EndNote
(.enl), Endnote XML (.xml), ISI
(.wos), MEDLINE (.medline), MODS
(.mods) and RIS (.ris).
For illustrative purposes, bibtex database is a plain text file with specific tag pairs to define the different components (fields) of a reference. To illustrate lets generate a bibtex database with two references.
@article{Bolker-2008-127,
author = {Bolker, B. M. and Brooks, M. E. and Clark, C. J. and Geange, S. W. and Poulsen,
J. R. and Stevens, H. H. and White, J. S.},
journal = {Trends in Ecology and Evolution},
number = {3},
pages = {127-135},
title = {Generalized linear mixed models: a practical guide for ecology and evolution},
volume = {24},
year = {2008}
}
@book{goossens93,
author = "Michel Goossens and Frank Mittlebach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
The bibtex format is one of the major formats provided for export by journals and databases like citeulike and crossref.
The bibliography can be referenced either via a
bibliography item in the YAML metadata or using the
--bibliography argument to pandoc. This points
to a file containing the bibliography.
Similarly, the citation style is determined via either the
csl YAML medata data item or the --csl pandoc
argument and should point to a Citation Style Language file. A large
selection of CSL files can be found in the Zostero Style
Repository. Additional styles can be found in a repository of
CSL 1.0 styles.
Incorporating citations requires the pandoc-citeproc
filter (and this must be included after the
pandoc-crossref filter (if this is included).
To include a citation, involves appending an at sign (@)
to the citation identifier. For example, @Bolker-2008-127.
If the item is enclosed in square braces, the associated in-text
citation will be enclosed in round brackets in the output. Additional
text can also be included within the square braces. For example,
[see @Bolker-2008-127].
If you are using Rstudio and have the citr
package loaded, then, if you select ‘Insert citations’ from the
the ‘Addins’ toolbar icon, you will be able to search your bibtex
bibliography and selected references will be added to your document.
Markdown (*.md)
---
title: This is the title
author: D. Author
date: 14-02-2013
bibliography: ../resources/references.bib
csl: ../resources/marine-pollution-bulletin.csl
---
# Introduction {#sec:intro}
@Quinn-2002-2002 described something important about ecological statistics in general.
Something important about generalized mixed models [@Bolker-2008-127].
# References
Ideally, reproducible research works best when the documentation and source codes are woven together into a single document. Traditionally, document preparation involved substantial quantities of ‘cutting and pasting’ from statistical software into document authoring tools such as LaTeX, html or Microsoft Word. Of course, any minor changes in the analyses then necessitated replacing the code in the document as well as replacing any affected figures or tables. Keeping everything synchronised was a bit of a battle.
Early implementations of reproducible research in R involved embedding chunks of R code between special tags within either HTML or LaTex documents. The file would then be parsed through specific R functions to evaluate each chunk and replace them with their tidied code and outputs in a process referred to as either weaving or knitting (depending on the function).
Over time the knitting routines (as supported by the knitr package) became more sophisticate. At the same time, knitr provided support for embedding R chunks into markdown. Here, markdown has begun to replace HTML and LaTeX as the base document because (as we illustrate above) it is both simple to use and can act as a universal language from which other formats can be generated.
Rmarkdown is essentially a markdown file with R (or many other languages) code embedded within specially marked chunks. Code chunks are defined as starting with the sequence ```{ and end with ```. For example, to define a simple R code chunk, we would include:
```{r name}
```
Any code that appears in the lines between the opening and closing chunk sequences will be evaluated by R. Similarly, other languages can also be used.
Importantly, to evaluate the code chunks embedded within an Rmarkdown document, the code is passed through a new R session. This means that although you might be testing the code in an R console (or Rstudio) as you write the code, it is important that the code be completely self contained. Therefore, if the code relies on a package or external function, these must be loaded as part of the script.
To see knitting in action, we will add an R code chunk to a markdown
document. When we knit this document, knitr will
convert the Rmarkdown file into a markdown file by evaluating any code
chunks and replacing them with formatted input and output markdown
fenced contents. Thereafter, we can use pandoc as we did
previously to convert this markdown into a variety of output
formats.
Rmarkdown (*.Rmd)
---
title: Example markdown
author: D. Author
date: 16-06-2020
---
# This is the title
```{r summary, eval=TRUE, results='markup'}
x <- rnorm(10)
summary(x)
`` `
echo 'library(knitr); knit("Example1.Rmd", output="Example1.md")' | R --no-save --no-restore
pandoc -o Example1.pdf Example1.md The above workflow is conveniently supported by an R package called
rmarkdown whose main function is to act as a wrapper for
knitting and running pandoc. As a very basic overview, the following
would render an Rmarkdown document as a pdf file.
The rmarkdown package comes with numerous output
formats. These include:
| Output format | rmarkdown name |
|---|---|
pdf_document (requires Tex) |
|
| HTML | html_document |
| DOCx | word_document |
| LaTeX | latex_document |
| ODT | odt_document |
| RTF | rtf_document |
| Github | github_document |
| Context | context_document |
| Markdown | md_document |
| ioslides presentation | ioslides_presentation |
| Slidy presentation | slidy_presentation |
| Powerpoint presentation | powerpoint_presentation |
| Beamer presentation | beamer_presentation (requires Tex) |
Additionally, the bookdown package contains versions of
many of these formats that provide support for more advanced features
(such as captions etc). These will be highlighted below where
appropriate.
To illustrate the basic use of the render() function,
lets process the above simple example file.
Rmarkdown (*.Rmd)
---
title: Example markdown
author: D. Author
date: 16-06-2020
---
# This is the title
```{r summary, eval=TRUE, results='markup'}
x <- rnorm(10)
summary(x)
`` `
As a minimum, it is advisable that each chunk be given a unique name
(name in the example above). There are numerous additional
arguments (options) that can be included in the chunk header. These
control the behaviour of the knitting process and the common ones are
listed in the following table.
| Option | Description |
|---|---|
| Code evaluations | |
| eval | either:
|
| include | TRUE or FALSE (whether to include the evaluated chunk in the output) |
| engine | the language used to evaluate the code chunk (default is ‘R’) |
| code | code to replace the code in the chunk |
| child | a character vector of (.Rmd) filenames to be evaluated and substituted in place of the chunk |
| Results | |
| echo | either:
|
| results | either:
|
| warning | either:
|
| error | either:
|
| message | either:
|
| Code decoration | |
| tidy | either:
|
| tidy.opts | a list of options passed on to the tidying function. For example,
tidy.opts=list(width.cutoff=60) |
| prompt | TRUE or FALSE (whether to include a command prompt as a prefex to each line of code |
| comment | the comment character used as a prefix to each output line (e.g. ##) |
| highlight | TRUE or FALSE (whether to apply syntax highlighting to the code) |
| size | the font size for code and output (only some document types) |
| strip.white | TRUE or FALSE (whether to remove leading spaces from code in output) |
| background | the color of the code and output background (only some document types) |
| Cache | |
| cache | TRUE or FALSE (whether to cache the chunk) Don’t cache chunks that load packages |
| dependson | a character vector of chunk names that this chunk depends on for the purpose of caching |
| Figures/plots | |
| fig.width,fig.height | the width and height (in inches) of generated plots |
| out.width,out.height | the width and height to resize the plots in the output |
| fig.cap | a character string to use as a figure caption |
| fig.align | ’default`, ‘left’, ‘right’, ‘center’ - alignment of plot on page |
Tables deserve and require special treatment hear. There are numerous routines (and packages) to support the elegant production of tables from R. Many of these routines are specific to a specific output format or else it is necessary to nominate which output format you require when calling the function.
That said, the kable function (which is part of
the knitr package) is able to be relatively
agnostic since it defaults to output in markdown table format. However,
markdown only supports very simple tables and thus if ta fable is forced
to go through a markdown funnel, many attributes (such as colours,
multicolumn headers, captions and labels) are lost.
To illustrate this, lets render a simple Rmarkdown table to PDF, HTML
and DOCX formats just using the kable function with all
defaults. For this example, we will use a built in data set
(BOD - biochemical oxygen demand).
---
title: This is the title
author: D. Author
date: 14-02-2013
---
```{r BODData}
knitr::kable(BOD)
`` `
HTML
DOCX
Not withstanding issues related to converting docx to png thumbnails
(via unoconv), the simple tables are produced in formats
that are broadly appropriate to the document type.
There are unfortunately a number of limitations to this simple approach to including tables:
Better support for referencing is provided by the
bookdown package. This package has richer versions
of many of the output formats defined in the rmarkdown
package and are distinguished from the rmarkdown
versions by a trailing 2. For example, the
bookdown version of a pdf document is called
pdf_document2. The bookdown package
also has additional formats that relate to online books etc.
If we only intend to output our document in a single format, then we
can achieve more complex table formatting via specific packages (such as
xtable for LaTeX tables), or activate output specific
options to broader packages/functions (such as
kable).
To illustrate the extended capabilities of the bookdown
package for tables, we will again use the BOD data
set. We will use a slightly different Rmarkdown for each of the pdf,
html and docx output formats.
Note in the following examples, I will intentionally
set echo=FASLE so as to exclude the chunk code in the
output.
For pdf, we will include more metadata (to specify the XeLaTeX engine, the article document class and Arial font for the main body). We have also included an initial R chunk in which we load a few packages (the later two for supporting the tables). The code within both chunks are suppressed from the output.
---
title: The title
output:
bookdown::pdf_document2:
latex_engine: xelatex
toc: no
documentclass: article
mainfont: Arial
...
```{r packages, message=FALSE, echo=FALSE}
library(tidyverse)
library(knitr)
library(kableExtra)
`` `
# Section 1
Bla bla (see Table \@ref(tab:BODData)).
(ref:tab-cap) Biochemical oxygen demand
```{r BODData, echo=FALSE, tab.pos='h'}
kable(BOD, caption="(ref:tab-cap)", format='latex', booktabs=TRUE) %>%
kable_styling(latex_options = "HOLD_position")
`` `
---
title: The title
output:
bookdown::html_document2:
toc: no
...
# Section 1
Bla bla (see Table \@ref(tab:BODData)).
(ref:tab-cap) Biochemical oxygen demand
```{r BODData, echo=FALSE}
knitr::kable(BOD, caption="(ref:tab-cap)", format='html', booktabs=TRUE)
`` `
Word tables are best serviced via flex tables. These
are supported by the flextable package.
---
title: The title
output:
bookdown::word_document2:
toc: no
...
# Section 1
Bla bla (see Table \@ref(tab:BODData)).
(ref:tab-cap) Biochemical oxygen demand
```{r BODData, echo=FALSE, tab.cap='(ref:tab-cap)'}
library(tidyverse)
library(flextable)
flextable::flextable(BOD) %>%
fontsize(size=8, part='all') %>%
bold(part='header')
`` `
If there is a need to have a single Rmarkdown source yield multiple
output formats (e.g. pdf, html and docx), we can specify the table code
conditional on output format (using a function in
knitr called to_pandoc()).
Rmarkdown (*.qmd)
---
title: The title
format:
html:
toc: false
docx:
toc: false
pdf:
latex_engine: xelatex
toc: false
geometry: paperwidth=12cm,paperheight=15cm,hmargin=1cm,vmargin=1cm
documentclass: article
mainfont: Arial
---
```{r}
#| label: packages
#| message: false
#| echo: false
library(tidyverse)
library(knitr)
library(kableExtra)
library(flextable)
`` `
# Section 1
Bla bla something about @tbl-boddata .
```{r}
#| label: tbl-boddata
#| echo: false
#| tbl-cap: Biochemical oxygen demand
if (knitr:::pandoc_to('latex')) {
kable(BOD, format='latex', booktabs=TRUE) %>%
kable_styling(latex_options = "HOLD_position")
} else if (knitr:::pandoc_to('html')) {
kable(BOD, format='html', booktabs=TRUE)
} else if (knitr:::pandoc_to('docx')) {
flextable(BOD) %>%
fontsize(size=8, part='all') %>%
bold(part='header')
}
`` `
Rmarkdown (*.Rmd)
---
title: The title
format:
html:
toc: false
docx:
toc: false
pdf:
latex_engine: xelatex
toc: false
geometry: paperwidth=12cm,paperheight=15cm,hmargin=1cm,vmargin=1cm
documentclass: article
mainfont: Arial
---
```{r}
#| label: packages
#| message: false
#| echo: false
library(tidyverse)
library(knitr)
`` `
# Section 1
Bla bla something about @fig-boddata .
```{r}
#| label: fig-boddata
#| echo: false
#| fig-cap: Biochemical oxygen demand
#| out-width: "60%"
ggplot(BOD) +
geom_point(aes(y=demand, x=Time))
`` `
Quarto has introduced the ability to add captions to inline graphics.
As an alternative, we can include external images using the
include_graphics() function in the
knitr package. Not only does this permit us to add
a caption (via the chunk option fig.cap=), we can also
specify the output size of the figure.
Similar to knitting tables above, we will illustrate adding external images via an Rmarkdown that supports multiple output formats.
Rmarkdown (*.Rmd)
---
title: The title
format:
html:
toc: false
docx:
toc: false
pdf:
latex_engine: xelatex
toc: false
geometry: paperwidth=12cm,paperheight=15cm,hmargin=1cm,vmargin=1cm
documentclass: article
mainfont: Arial
---
```{r}
#| label: packages
#| message: false
#| echo: false
library(tidyverse)
library(knitr)
library(kableExtra)
library(flextable)
`` `
# Section 1
{#fig-aimswq width=20%}
We can refer to the figures as see @fig-aimswq and @fig-aimswq1 .
```{r AIMSwq}
#| label: fig-aimswq1
#| echo: false
#| fig-cap: AIMS water quality sampling
#| out-width: "20%"
include_graphics('AIMS_wq.jpg')
`` `
Recall that the meta data of a markdown file is defined in a special YAML block (which is normally, yet not necessarily, positioned at the top of the markdown file). In the examples above, the YAML block was used to define the title, an author, date and bibliography and can to specify some settings associated with the broad type of output (PDF, HTML, Word).
The YAML block is also used to determine the style and formatting of the output. In this section, we will explore some of the major customisations available from small changes to the YAML block.
The following table lists the main simple customizations that can be
applied and which document type they can be applied to. In the table
(yes/no) are the same as
(true/false). Values in square braces are
alternatives to the default values. I have purposely used settings (in
the Options column) that contrast the default settings so that the
effects are very obvious. They do not constitute any form of
recommendation.
| Option | Description | HTML | Word (docx) | |
|---|---|---|---|---|
toc: true |
Include a table of contents (default: no) |
✔ | ✔ | ✔ |
toc_depth: 2 |
Depth of the table of contents (default: 3) |
✔ | ✔ | ✔ |
number_sections: yes |
Number the sections (default: no) |
✔ | ✔ | ✖ |
fig_width: 5 |
Width of figures in inches (default: 6) |
✔ | ✔ | ✔ |
fig_height: 5 |
Height of figures in inches (default: 4.5) |
✔ | ✔ | ✔ |
df_print: kable |
Processing of data.frames (default: default)
[kable,tibble,paged] |
✔ | ✔ | ✔ |
highlight: zenburn |
R code syntax highlighting (default: default)
[tango, pygments, kate, monochrome, espresso, zenburn,
haddock, textmate] |
✔ | ✔ | ✔ |
code_folding: hide |
Hide/reveal code blocks in output (default: none)
[show,hide] |
✖ | ✔ | ✖ |
theme: spacelab |
A pre-packaged page theme (default: default)
[cerulean, journal, flatly, readable, spacelab, united,
cosmo, lumen, paper, sandstone, simplex, yeti] |
✖ | ✔ | ✖ |
latex_engine: xelatex |
The LaTeX engine to use (default: pdflatex)
[xelatex, lualatex] |
✔ | ✖ | ✖ |
Lets now explore what the effect of the above customizations have on
the output format of a very simple Rmarkdown document.. As with the
previous example, the YAML header will include options for all three
output formats (pdf, html and docx). If we were to render an Rmarkdown
document with the above YAML block via the render()
function (and without providing the output_format
argument), the underlying engine will attempt to generate a PDF
file (since the pdf_document is the first one defined in
the YAML block). However, if we do specify a different
output_format argument, the associated
customizations will be applied when rendering the document. The
customizations can be different for each of the document types (PDF,
HTML and Word).
Rmarkdown (*.Rmd)
---
title: The title
format:
html:
toc: true
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
highlight: zenburn
df_print: kable
code_folding: hide
theme: spacelab
docx:
toc: true
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
highlight: zenburn
df_print: kable
pdf:
latex_engine: xelatex
toc: true
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
highlight: zenburn
df_print: kable
geometry: paperwidth=12cm,paperheight=15cm,hmargin=1cm,vmargin=1cm
documentclass: article
mainfont: Arial
---
```{r}
#| label: packages
#| message: false
#| echo: false
library(tidyverse)
library(knitr)
`` `
# Section 1
Text with embedded R code.
```{r Summary}
mean(rnorm(10))
`` `
```{r head}
head(cars)
`` `
## Subsection 1
We can include a figure
```{r Plot, fig.cap='Gaussian density.',message=FALSE}
library(tidyverse)
data.frame(x=rnorm(1000)) %>%
ggplot(aes(x=x)) + geom_density()
`` `
Perhaps even a table
```{r table}
library(knitr)
kable(summary(cars), caption='Summary of the cars data set')
`` `
In addition to the above settings that can be applied to different output formats and yet are specified as third-level arguments (that is under each document type), there are also settings that can be applied to multiple output document formats yet that are applied as top-level arguments. These are listed in the following table and example outputs.
| Option | Description |
|---|---|
fontsize: 10pt |
Document font size [10pt, 11pt, 12pt] |
| abstract: This is the abstract… | An abstract |
Although Rmarkdown (along with knitr and
pandoc) is the Swiss Army knife of document preparation –
in that the same source document can be used to produce multiple output
formats – each of these three formats provide different utilities. As
such, it is often desirable to customize the outputs to make best use of
different formats.
PDF documents provide a good way to communicate research in a a controlled and universal manner. In this render workflow, PDF documents are created via LaTeX. Styling in LaTeX is controlled via macros defined in the document preamble. Hence, major customizations are brought about by dictating changes to the preamble.
HTML documents provide the presentation of dynamic content. Styling in HTML documents is largely controlled via style sheets and/or scripts (particularly javascript).
Word documents provide a document format that is accessable to non-scientists. Styling in Word is provided by the element styles defined in the document itself - which are often imposed by a template.
Since styling is each of these formats is quite different and as some of these customizations can get extensive, we will treat each document type separately in the following sections.
The styling information in LaTeX is defined in the document preamble. A markdown LaTeX template is essentially a skeleton LaTeX document with an extensive collection of conditional statements that allow the preamble to be customized based on the options indicated in the markdown YAML header.
The preable of a LaTeX document defines a document class followed by a series of macros (similar to constants and functions in other languages) that define the settings and styling of the document.
When pandoc converts a markdown document into a LaTeX
document, it accesses a template which is used to generate the preable
for the LaTeX document. The template system is designed so that
information specified in the YAML block of the markdown document can be
used to govern certain aspects of the resulting LaTeX preamble
The following table, lists some of the customizations that can be included as top-level (not indented) YAML meta data for PDF output. Note, these can be present when rendering to other formats, they will just be ignored.
| Option | Description |
|---|---|
documentclass: book |
LaTeX document class (default: article, minimal)
[book] |
classoption: a4paper |
Options for the documentclass [oneside,a4paper] |
geometry: margin=1cm |
Options for the geometry class |
fontsize: 11pt |
The size of the base font (default: 12pt) |
fontfamily: mathpazo |
Document fonts (only available when using pdflatex |
mainfont: Arial |
Document fonts (only available when using xelatex) |
sansfont: Arial |
Document fonts (only available when using xelatex) |
monofont: Arial |
Document fonts (only available when using xelatex) |
mathfont: Arial |
Document fonts (only available when using xelatex) |
linkcolor: blue |
Colour of internal links |
urlcolor: blue |
Colour of external links |
citecolor: blue |
Colour of citation links |
A list of available system fonts available to LaTeX can be obtained by issuing the following commands (in a terminal):
fc-list --format="%{family[0]}\n" | sort | uniq
Alternatively, within R:
## [1] "Source Code Pro Black" "Source Code Pro"
## [3] "Source Code Pro ExtraLight" "Source Code Pro Light"
## [5] "Source Code Pro Medium" "Source Code Pro Semibold"
## [7] "SourceCodeVF" "Source Han Sans CN"
## [9] "Source Han Sans CN ExtraLight" "Source Han Sans CN Heavy"
## [11] "Source Han Sans CN Light" "Source Han Sans CN Medium"
## [13] "Source Han Sans CN Normal" "Source Han Sans JP"
## [15] "Source Han Sans JP ExtraLight" "Source Han Sans JP Heavy"
## [17] "Source Han Sans JP Light" "Source Han Sans JP Medium"
## [19] "Source Han Sans JP Normal" "Source Han Sans KR"
## [21] "Source Han Sans KR ExtraLight" "Source Han Sans KR Heavy"
## [23] "Source Han Sans KR Light" "Source Han Sans KR Medium"
## [25] "Source Han Sans KR Normal" "Source Sans 3 Black"
## [27] "Source Sans 3" "Source Sans 3 ExtraLight"
## [29] "Source Sans 3 Light" "Source Sans 3 Medium"
## [31] "Source Sans 3 Semibold" "SourceSans3VF"
## [33] "Source Sans Pro Black" "Source Sans Pro"
## [35] "Source Sans Pro ExtraLight" "Source Sans Pro Light"
## [37] "Source Sans Pro Semibold" "Source Sans Variable"
## [39] "FontAwesome" "octicons"
## [41] "Pomodoro" "Cantarell"
## [43] "Droid Arabic Kufi" "Droid Arabic Naskh"
## [45] "Droid Naskh Shift Alt" "Droid Sans"
## [47] "Droid Sans Arabic" "Droid Sans Armenian"
## [49] "Droid Sans Devanagari" "Droid Sans Ethiopic"
## [51] "Droid Sans Fallback" "Droid Sans Georgian"
## [53] "Droid Sans Hebrew" "Droid Sans Japanese"
## [55] "Droid Sans Mono" "Droid Sans Tamil"
## [57] "Droid Sans Thai" "Droid Serif"
## [59] "C059" "D050000L"
## [61] "Nimbus Mono PS" "Nimbus Roman"
## [63] "Nimbus Sans" "Nimbus Sans Narrow"
## [65] "P052" "Standard Symbols PS"
## [67] "URW Bookman" "URW Gothic"
## [69] "Z003" "Liberation Mono"
## [71] "Liberation Sans" "Liberation Serif"
## [73] "Noto Fangsong KSS Rotated" "Noto Fangsong KSS Vertical"
## [75] "Noto Looped Thai Black" "Noto Looped Thai"
## [77] "Noto Looped Thai Light" "Noto Looped Thai Medium"
## [79] "Noto Looped Thai Thin" "Noto Music"
## [81] "Noto Naskh Arabic" "Noto Naskh Arabic Medium"
## [83] "Noto Naskh Arabic UI" "Noto Naskh Arabic UI Medium"
## [85] "Noto Nastaliq Urdu" "Noto Rashi Hebrew Black"
## [87] "Noto Rashi Hebrew" "Noto Rashi Hebrew Light"
## [89] "Noto Rashi Hebrew Medium" "Noto Rashi Hebrew Thin"
## [91] "Noto Sans Black" "Noto Sans"
## [93] "Noto Sans Light" "Noto Sans Medium"
## [95] "Noto Sans Thin" "Noto Sans Adlam"
## [97] "Noto Sans Adlam Unjoined" "Noto Sans Anatolian Hieroglyphs"
## [99] "Noto Sans Arabic Black" "Noto Sans Arabic"
## [101] "Noto Sans Arabic Light" "Noto Sans Arabic Medium"
## [103] "Noto Sans Arabic Thin" "Noto Sans Armenian Black"
## [105] "Noto Sans Armenian" "Noto Sans Armenian Light"
## [107] "Noto Sans Armenian Medium" "Noto Sans Armenian Thin"
## [109] "Noto Sans Avestan" "Noto Sans Balinese"
## [111] "Noto Sans Balinese Medium" "Noto Sans Bamum"
## [113] "Noto Sans Bamum Medium" "Noto Sans Bassa Vah"
## [115] "Noto Sans Bassa Vah Medium" "Noto Sans Batak"
## [117] "Noto Sans Bengali Black" "Noto Sans Bengali"
## [119] "Noto Sans Bengali Light" "Noto Sans Bengali Medium"
## [121] "Noto Sans Bengali Thin" "Noto Sans Bengali UI Black"
## [123] "Noto Sans Bengali UI" "Noto Sans Bengali UI Light"
## [125] "Noto Sans Bengali UI Medium" "Noto Sans Bengali UI Thin"
## [127] "Noto Sans Bhaiksuki" "Noto Sans Brahmi"
## [129] "Noto Sans Buginese" "Noto Sans Buhid"
## [131] "Noto Sans Canadian Aboriginal Black" "Noto Sans Canadian Aboriginal"
## [133] "Noto Sans Canadian Aboriginal Light" "Noto Sans Canadian Aboriginal Medium"
## [135] "Noto Sans Canadian Aboriginal Thin" "Noto Sans Carian"
## [137] "Noto Sans Caucasian Albanian" "Noto Sans Chakma"
## [139] "Noto Sans Cham Black" "Noto Sans Cham"
## [141] "Noto Sans Cham Light" "Noto Sans Cham Medium"
## [143] "Noto Sans Cham Thin" "Noto Sans Cherokee Black"
## [145] "Noto Sans Cherokee" "Noto Sans Cherokee Light"
## [147] "Noto Sans Cherokee Medium" "Noto Sans Cherokee Thin"
## [149] "Noto Sans Chorasmian" "Noto Sans Coptic"
## [151] "Noto Sans Cuneiform" "Noto Sans Cypriot"
## [153] "Noto Sans Cypro Minoan" "Noto Sans Deseret"
## [155] "Noto Sans Devanagari Black" "Noto Sans Devanagari"
## [157] "Noto Sans Devanagari Light" "Noto Sans Devanagari Medium"
## [159] "Noto Sans Devanagari Thin" "Noto Sans Devanagari UI Black"
## [161] "Noto Sans Devanagari UI" "Noto Sans Devanagari UI Light"
## [163] "Noto Sans Devanagari UI Medium" "Noto Sans Devanagari UI Thin"
## [165] "Noto Sans Duployan" "Noto Sans Egyptian Hieroglyphs"
## [167] "Noto Sans Elbasan" "Noto Sans Elymaic"
## [169] "Noto Sans Ethiopic Black" "Noto Sans Ethiopic"
## [171] "Noto Sans Ethiopic Light" "Noto Sans Ethiopic Medium"
## [173] "Noto Sans Ethiopic Thin" "Noto Sans Georgian Black"
## [175] "Noto Sans Georgian" "Noto Sans Georgian Light"
## [177] "Noto Sans Georgian Medium" "Noto Sans Georgian Thin"
## [179] "Noto Sans Glagolitic" "Noto Sans Gothic"
## [181] "Noto Sans Grantha" "Noto Sans Gujarati Black"
## [183] "Noto Sans Gujarati" "Noto Sans Gujarati Light"
## [185] "Noto Sans Gujarati Medium" "Noto Sans Gujarati Thin"
## [187] "Noto Sans Gujarati UI Black" "Noto Sans Gujarati UI"
## [189] "Noto Sans Gujarati UI Light" "Noto Sans Gujarati UI Medium"
## [191] "Noto Sans Gujarati UI Thin" "Noto Sans Gunjala Gondi"
## [193] "Noto Sans Gunjala Gondi Medium" "Noto Sans Gurmukhi Black"
## [195] "Noto Sans Gurmukhi" "Noto Sans Gurmukhi Light"
## [197] "Noto Sans Gurmukhi Medium" "Noto Sans Gurmukhi Thin"
## [199] "Noto Sans Gurmukhi UI Black" "Noto Sans Gurmukhi UI"
## [201] "Noto Sans Gurmukhi UI Light" "Noto Sans Gurmukhi UI Medium"
## [203] "Noto Sans Gurmukhi UI Thin" "Noto Sans Hanifi Rohingya"
## [205] "Noto Sans Hanifi Rohingya Medium" "Noto Sans Hanunoo"
## [207] "Noto Sans Hatran" "Noto Sans Hebrew Black"
## [209] "Noto Sans Hebrew" "Noto Sans Hebrew Light"
## [211] "Noto Sans Hebrew Medium" "Noto Sans Hebrew Thin"
## [213] "Noto Sans Imperial Aramaic" "Noto Sans Indic Siyaq Numbers"
## [215] "Noto Sans Inscriptional Pahlavi" "Noto Sans Inscriptional Parthian"
## [217] "Noto Sans Javanese" "Noto Sans Kaithi"
## [219] "Noto Sans Kannada Black" "Noto Sans Kannada"
## [221] "Noto Sans Kannada Light" "Noto Sans Kannada Medium"
## [223] "Noto Sans Kannada Thin" "Noto Sans Kannada UI Black"
## [225] "Noto Sans Kannada UI" "Noto Sans Kannada UI Light"
## [227] "Noto Sans Kannada UI Medium" "Noto Sans Kannada UI Thin"
## [229] "Noto Sans Kayah Li" "Noto Sans Kayah Li Medium"
## [231] "Noto Sans Kharoshthi" "Noto Sans Khmer Black"
## [233] "Noto Sans Khmer" "Noto Sans Khmer Light"
## [235] "Noto Sans Khmer Medium" "Noto Sans Khmer Thin"
## [237] "Noto Sans Khojki" "Noto Sans Khudawadi"
## [239] "Noto Sans Lao Black" "Noto Sans Lao"
## [241] "Noto Sans Lao Light" "Noto Sans Lao Medium"
## [243] "Noto Sans Lao Thin" "Noto Sans Lao Looped Black"
## [245] "Noto Sans Lao Looped" "Noto Sans Lao Looped Light"
## [247] "Noto Sans Lao Looped Medium" "Noto Sans Lao Looped Thin"
## [249] "Noto Sans Lepcha" "Noto Sans Limbu"
## [251] "Noto Sans Linear A" "Noto Sans Linear B"
## [253] "Noto Sans Lisu" "Noto Sans Lisu Medium"
## [255] "Noto Sans Lycian" "Noto Sans Lydian"
## [257] "Noto Sans Mahajani" "Noto Sans Malayalam Black"
## [259] "Noto Sans Malayalam" "Noto Sans Malayalam Light"
## [261] "Noto Sans Malayalam Medium" "Noto Sans Malayalam Thin"
## [263] "Noto Sans Malayalam UI Black" "Noto Sans Malayalam UI"
## [265] "Noto Sans Malayalam UI Light" "Noto Sans Malayalam UI Medium"
## [267] "Noto Sans Malayalam UI Thin" "Noto Sans Mandaic"
## [269] "Noto Sans Manichaean" "Noto Sans Marchen"
## [271] "Noto Sans Masaram Gondi" "Noto Sans Math"
## [273] "Noto Sans Mayan Numerals" "Noto Sans Medefaidrin"
## [275] "Noto Sans Medefaidrin Medium" "Noto Sans Meetei Mayek Black"
## [277] "Noto Sans Meetei Mayek" "Noto Sans Meetei Mayek Light"
## [279] "Noto Sans Meetei Mayek Medium" "Noto Sans Meetei Mayek Thin"
## [281] "Noto Sans Mende Kikakui" "Noto Sans Meroitic"
## [283] "Noto Sans Miao" "Noto Sans Modi"
## [285] "Noto Sans Mongolian" "Noto Sans Mono Black"
## [287] "Noto Sans Mono" "Noto Sans Mono Light"
## [289] "Noto Sans Mono Medium" "Noto Sans Mono Thin"
## [291] "Noto Sans Mro" "Noto Sans Multani"
## [293] "Noto Sans Myanmar Black" "Noto Sans Myanmar"
## [295] "Noto Sans Myanmar Light" "Noto Sans Myanmar Medium"
## [297] "Noto Sans Myanmar Thin" "Noto Sans Nabataean"
## [299] "Noto Sans Nag Mundari" "Noto Sans Nandinagari"
## [301] "Noto Sans Newa" "Noto Sans New Tai Lue"
## [303] "Noto Sans New Tai Lue Medium" "Noto Sans NKo"
## [305] "Noto Sans Nushu" "Noto Sans Ogham"
## [307] "Noto Sans Ol Chiki" "Noto Sans Ol Chiki Medium"
## [309] "Noto Sans Old Hungarian" "Noto Sans Old Italic"
## [311] "Noto Sans Old North Arabian" "Noto Sans Old Permic"
## [313] "Noto Sans Old Persian" "Noto Sans Old Sogdian"
## [315] "Noto Sans Old South Arabian" "Noto Sans Old Turkic"
## [317] "Noto Sans Oriya Black" "Noto Sans Oriya"
## [319] "Noto Sans Oriya Thin" "Noto Sans Osage"
## [321] "Noto Sans Osmanya" "Noto Sans Pahawh Hmong"
## [323] "Noto Sans Palmyrene" "Noto Sans Pau Cin Hau"
## [325] "Noto Sans Phags-Pa" "Noto Sans Phoenician"
## [327] "Noto Sans Psalter Pahlavi" "Noto Sans Rejang"
## [329] "Noto Sans Runic" "Noto Sans Samaritan"
## [331] "Noto Sans Saurashtra" "Noto Sans Sharada"
## [333] "Noto Sans Shavian" "Noto Sans Siddham"
## [335] "Noto Sans SignWriting" "Noto Sans Sinhala Black"
## [337] "Noto Sans Sinhala" "Noto Sans Sinhala Light"
## [339] "Noto Sans Sinhala Medium" "Noto Sans Sinhala Thin"
## [341] "Noto Sans Sinhala UI Black" "Noto Sans Sinhala UI"
## [343] "Noto Sans Sinhala UI Light" "Noto Sans Sinhala UI Medium"
## [345] "Noto Sans Sinhala UI Thin" "Noto Sans Sogdian"
## [347] "Noto Sans Sora Sompeng" "Noto Sans Sora Sompeng Medium"
## [349] "Noto Sans Soyombo" "Noto Sans Sundanese"
## [351] "Noto Sans Sundanese Medium" "Noto Sans Syloti Nagri"
## [353] "Noto Sans Symbols Black" "Noto Sans Symbols"
## [355] "Noto Sans Symbols Light" "Noto Sans Symbols Medium"
## [357] "Noto Sans Symbols Thin" "Noto Sans Symbols 2"
## [359] "Noto Sans Syriac Black" "Noto Sans Syriac"
## [361] "Noto Sans Syriac Thin" "Noto Sans Syriac Eastern Black"
## [363] "Noto Sans Syriac Eastern" "Noto Sans Syriac Eastern Thin"
## [365] "Noto Sans Syriac Western Black" "Noto Sans Syriac Western"
## [367] "Noto Sans Syriac Western Thin" "Noto Sans Tagalog"
## [369] "Noto Sans Tagbanwa" "Noto Sans Tai Le"
## [371] "Noto Sans Tai Tham" "Noto Sans Tai Tham Medium"
## [373] "Noto Sans Tai Viet" "Noto Sans Takri"
## [375] "Noto Sans Tamil Black" "Noto Sans Tamil"
## [377] "Noto Sans Tamil Light" "Noto Sans Tamil Medium"
## [379] "Noto Sans Tamil Thin" "Noto Sans Tamil Supplement"
## [381] "Noto Sans Tamil UI Black" "Noto Sans Tamil UI"
## [383] "Noto Sans Tamil UI Light" "Noto Sans Tamil UI Medium"
## [385] "Noto Sans Tamil UI Thin" "Noto Sans Tangsa"
## [387] "Noto Sans Tangsa Medium" "Noto Sans Telugu Black"
## [389] "Noto Sans Telugu" "Noto Sans Telugu Light"
## [391] "Noto Sans Telugu Medium" "Noto Sans Telugu Thin"
## [393] "Noto Sans Telugu UI Black" "Noto Sans Telugu UI"
## [395] "Noto Sans Telugu UI Light" "Noto Sans Telugu UI Medium"
## [397] "Noto Sans Telugu UI Thin" "Noto Sans Test"
## [399] "Noto Sans Thaana Black" "Noto Sans Thaana"
## [401] "Noto Sans Thaana Light" "Noto Sans Thaana Medium"
## [403] "Noto Sans Thaana Thin" "Noto Sans Thai Black"
## [405] "Noto Sans Thai" "Noto Sans Thai Light"
## [407] "Noto Sans Thai Medium" "Noto Sans Thai Thin"
## [409] "Noto Sans Thai Looped Black" "Noto Sans Thai Looped"
## [411] "Noto Sans Thai Looped Light" "Noto Sans Thai Looped Medium"
## [413] "Noto Sans Thai Looped Thin" "Noto Sans Tifinagh"
## [415] "Noto Sans Tifinagh Adrar" "Noto Sans Tifinagh Agraw Imazighen"
## [417] "Noto Sans Tifinagh Ahaggar" "Noto Sans Tifinagh Air"
## [419] "Noto Sans Tifinagh APT" "Noto Sans Tifinagh Azawagh"
## [421] "Noto Sans Tifinagh Ghat" "Noto Sans Tifinagh Hawad"
## [423] "Noto Sans Tifinagh Rhissa Ixa" "Noto Sans Tifinagh SIL"
## [425] "Noto Sans Tifinagh Tawellemmet" "Noto Sans Tirhuta"
## [427] "Noto Sans Ugaritic" "Noto Sans Vai"
## [429] "Noto Sans Vithkuqi" "Noto Sans Vithkuqi Medium"
## [431] "Noto Sans Wancho" "Noto Sans Warang Citi"
## [433] "Noto Sans Yi" "Noto Sans Zanabazar Square"
## [435] "Noto Serif Black" "Noto Serif"
## [437] "Noto Serif Light" "Noto Serif Medium"
## [439] "Noto Serif Thin" "Noto Serif Ahom"
## [441] "Noto Serif Armenian Black" "Noto Serif Armenian"
## [443] "Noto Serif Armenian Light" "Noto Serif Armenian Medium"
## [445] "Noto Serif Armenian Thin" "Noto Serif Balinese"
## [447] "Noto Serif Bengali Black" "Noto Serif Bengali"
## [449] "Noto Serif Bengali Light" "Noto Serif Bengali Medium"
## [451] "Noto Serif Bengali Thin" "Noto Serif Devanagari Black"
## [453] "Noto Serif Devanagari" "Noto Serif Devanagari Light"
## [455] "Noto Serif Devanagari Medium" "Noto Serif Devanagari Thin"
## [457] "Noto Serif Display Black" "Noto Serif Display"
## [459] "Noto Serif Display Light" "Noto Serif Display Medium"
## [461] "Noto Serif Display Thin" "Noto Serif Dives Akuru"
## [463] "Noto Serif Dogra" "Noto Serif Ethiopic Black"
## [465] "Noto Serif Ethiopic" "Noto Serif Ethiopic Light"
## [467] "Noto Serif Ethiopic Medium" "Noto Serif Ethiopic Thin"
## [469] "Noto Serif Georgian Black" "Noto Serif Georgian"
## [471] "Noto Serif Georgian Light" "Noto Serif Georgian Medium"
## [473] "Noto Serif Georgian Thin" "Noto Serif Grantha"
## [475] "Noto Serif Gujarati Black" "Noto Serif Gujarati"
## [477] "Noto Serif Gujarati Light" "Noto Serif Gujarati Medium"
## [479] "Noto Serif Gujarati Thin" "Noto Serif Gurmukhi Black"
## [481] "Noto Serif Gurmukhi" "Noto Serif Gurmukhi Light"
## [483] "Noto Serif Gurmukhi Medium" "Noto Serif Gurmukhi Thin"
## [485] "Noto Serif Hebrew Black" "Noto Serif Hebrew"
## [487] "Noto Serif Hebrew Light" "Noto Serif Hebrew Medium"
## [489] "Noto Serif Hebrew Thin" "Noto Serif Kannada Black"
## [491] "Noto Serif Kannada" "Noto Serif Kannada Light"
## [493] "Noto Serif Kannada Medium" "Noto Serif Kannada Thin"
## [495] "Noto Serif Khitan Small Script" "Noto Serif Khmer Black"
## [497] "Noto Serif Khmer" "Noto Serif Khmer Light"
## [499] "Noto Serif Khmer Medium" "Noto Serif Khmer Thin"
## [501] "Noto Serif Khojki" "Noto Serif Lao Black"
## [503] "Noto Serif Lao" "Noto Serif Lao Light"
## [505] "Noto Serif Lao Medium" "Noto Serif Lao Thin"
## [507] "Noto Serif Makasar" "Noto Serif Malayalam Black"
## [509] "Noto Serif Malayalam" "Noto Serif Malayalam Light"
## [511] "Noto Serif Malayalam Medium" "Noto Serif Malayalam Thin"
## [513] "Noto Serif Myanmar Black" "Noto Serif Myanmar"
## [515] "Noto Serif Myanmar Light" "Noto Serif Myanmar Medium"
## [517] "Noto Serif Myanmar Thin" "Noto Serif NP Hmong"
## [519] "Noto Serif NP Hmong Medium" "Noto Serif Old Uyghur"
## [521] "Noto Serif Oriya" "Noto Serif Oriya Medium"
## [523] "Noto Serif Ottoman Siyaq" "Noto Serif Sinhala Black"
## [525] "Noto Serif Sinhala" "Noto Serif Sinhala Light"
## [527] "Noto Serif Sinhala Medium" "Noto Serif Sinhala Thin"
## [529] "Noto Serif Tamil Black" "Noto Serif Tamil"
## [531] "Noto Serif Tamil Light" "Noto Serif Tamil Medium"
## [533] "Noto Serif Tamil Thin" "Noto Serif Tangut"
## [535] "Noto Serif Telugu Black" "Noto Serif Telugu"
## [537] "Noto Serif Telugu Light" "Noto Serif Telugu Medium"
## [539] "Noto Serif Telugu Thin" "Noto Serif Test"
## [541] "Noto Serif Thai Black" "Noto Serif Thai"
## [543] "Noto Serif Thai Light" "Noto Serif Thai Medium"
## [545] "Noto Serif Thai Thin" "Noto Serif Tibetan Black"
## [547] "Noto Serif Tibetan" "Noto Serif Tibetan Light"
## [549] "Noto Serif Tibetan Medium" "Noto Serif Tibetan Thin"
## [551] "Noto Serif Toto" "Noto Serif Toto Medium"
## [553] "Noto Serif Vithkuqi" "Noto Serif Vithkuqi Medium"
## [555] "Noto Serif Yezidi" "Noto Serif Yezidi Medium"
## [557] "Noto Traditional Nushu" "Noto Traditional Nushu Light"
## [559] "Distortion Dos Digital" "1942 report"
## [561] "Aliquam" "Andale Mono"
## [563] "Arial" "Arial Black"
## [565] "Bootcamp" "Calibri"
## [567] "Cambria Math" "Cambria"
## [569] "Candara" "Comic Sans MS"
## [571] "Consolas" "Constantia"
## [573] "Corbel" "Courier New"
## [575] "DejaVu Math TeX Gyre" "DejaVu Sans"
## [577] "DejaVu Sans Light" "DejaVu Sans Condensed"
## [579] "DejaVu Sans Mono" "DejaVu Serif"
## [581] "DejaVu Serif Condensed" "Delicious Adventures"
## [583] "Desyrel" "Digital Readout Thick Upright"
## [585] "Font Awesome 6 Brands Regular" "Font Awesome 6 Free Regular"
## [587] "Font Awesome 6 Free Solid" "Font Awesome v4 Compatibility Regular"
## [589] "Georgia" "Hack"
## [591] "Impact" "Inconsolata Black"
## [593] "Inconsolata" "Inconsolata Condensed"
## [595] "Inconsolata Condensed Black" "Inconsolata Condensed Bold"
## [597] "Inconsolata Condensed ExtraBold" "Inconsolata Condensed ExtraLight"
## [599] "Inconsolata Condensed Light" "Inconsolata Condensed Medium"
## [601] "Inconsolata Condensed SemiBold" "Inconsolata Expanded"
## [603] "Inconsolata Expanded Black" "Inconsolata Expanded Bold"
## [605] "Inconsolata Expanded ExtraBold" "Inconsolata Expanded ExtraLight"
## [607] "Inconsolata Expanded Light" "Inconsolata Expanded Medium"
## [609] "Inconsolata Expanded SemiBold" "Inconsolata ExtraBold"
## [611] "Inconsolata Extra Condensed" "Inconsolata Extra Condensed Black"
## [613] "Inconsolata Extra Condensed Bold" "Inconsolata Extra Condensed ExtraBold"
## [615] "Inconsolata Extra Condensed ExtraLight" "Inconsolata Extra Condensed Light"
## [617] "Inconsolata Extra Condensed Medium" "Inconsolata Extra Condensed SemiBold"
## [619] "Inconsolata Extra Expanded" "Inconsolata Extra Expanded Black"
## [621] "Inconsolata Extra Expanded Bold" "Inconsolata Extra Expanded ExtraBold"
## [623] "Inconsolata Extra Expanded ExtraLight" "Inconsolata Extra Expanded Light"
## [625] "Inconsolata Extra Expanded Medium" "Inconsolata Extra Expanded SemiBold"
## [627] "Inconsolata ExtraLight" "Inconsolata Light"
## [629] "Inconsolata Medium" "Inconsolata SemiBold"
## [631] "Inconsolata Semi Condensed" "Inconsolata Semi Condensed Black"
## [633] "Inconsolata Semi Condensed Bold" "Inconsolata Semi Condensed ExtraBold"
## [635] "Inconsolata Semi Condensed ExtraLight" "Inconsolata Semi Condensed Light"
## [637] "Inconsolata Semi Condensed Medium" "Inconsolata Semi Condensed SemiBold"
## [639] "Inconsolata Semi Expanded" "Inconsolata Semi Expanded Black"
## [641] "Inconsolata Semi Expanded Bold" "Inconsolata Semi Expanded ExtraBold"
## [643] "Inconsolata Semi Expanded ExtraLight" "Inconsolata Semi Expanded Light"
## [645] "Inconsolata Semi Expanded Medium" "Inconsolata Semi Expanded SemiBold"
## [647] "Inconsolata Ultra Condensed" "Inconsolata Ultra Condensed Black"
## [649] "Inconsolata Ultra Condensed Bold" "Inconsolata Ultra Condensed ExtraBold"
## [651] "Inconsolata Ultra Condensed ExtraLight" "Inconsolata Ultra Condensed Light"
## [653] "Inconsolata Ultra Condensed Medium" "Inconsolata Ultra Condensed SemiBold"
## [655] "Inconsolata Ultra Expanded" "Inconsolata Ultra Expanded Black"
## [657] "Inconsolata Ultra Expanded Bold" "Inconsolata Ultra Expanded ExtraBold"
## [659] "Inconsolata Ultra Expanded ExtraLight" "Inconsolata Ultra Expanded Light"
## [661] "Inconsolata Ultra Expanded Medium" "Inconsolata Ultra Expanded SemiBold"
## [663] "JetBrains Mono" "JetBrains Mono ExtraBold"
## [665] "JetBrains Mono ExtraLight" "JetBrains Mono Light"
## [667] "JetBrains Mono Medium" "JetBrains Mono SemiBold"
## [669] "JetBrains Mono Thin" "JetBrains Mono NL"
## [671] "JetBrains Mono NL ExtraBold" "JetBrains Mono NL ExtraLight"
## [673] "JetBrains Mono NL Light" "JetBrains Mono NL Medium"
## [675] "JetBrains Mono NL SemiBold" "JetBrains Mono NL Thin"
## [677] "Ligconsolata" "Meiryo"
## [679] "OpenLogos" "Open Sans"
## [681] "Open Sans ExtraBold" "Open Sans Light"
## [683] "Open Sans SemiBold" "Open Sans Condensed"
## [685] "Open Sans Condensed Light" "Paskowy"
## [687] "PF Tempesta Five Condensed" "Poky"
## [689] "Roboto" "Roboto Condensed"
## [691] "Santana-Black" "Santana-BlackCondensed"
## [693] "Santana" "Santana-RegularCondensed"
## [695] "SantanaXtraCondensed" "Space Age"
## [697] "StyleBats" "Technical CE"
## [699] "Times New Roman" "Trebuchet MS"
## [701] "Bitstream Vera Sans" "Bitstream Vera Sans Mono"
## [703] "Bitstream Vera Serif" "Verdana"
## [705] "Webdings" "Xirod"
## [707] "Zekton Rg" "Ubuntu"
## [709] "Ubuntu Condensed" "Ubuntu Light"
## [711] "Ubuntu Mono"
quarto (*.qmd)
---
title: The title
format:
pdf:
latex_engine: xelatex
toc: true
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
highlight: zenburn
df_print: kable
documentclass: article
classoption: a4paper
mainfont: Arial
mathfont: LiberationMono
monofont: DejaVu Sans Mono
abstract: This is the abstract
urlcolor: red
---
# Section 1
Text with embedded R code.
```{r}
#| label: Summary
mean(rnorm(10))
`` `
```{r}
#| label: head
head(cars)
`` `
$$
y_i = \beta_0 + \beta_1 x_i
$$
## Subsection 1
We can include a figure
```{r Plot, fig.cap='Gaussian density.',message=FALSE}
#| label: Plot
#| fig-cap: Gaussian density
#| message: false
library(tidyverse)
data.frame(x=rnorm(1000)) %>%
ggplot(aes(x=x)) + geom_density()
`` `
Perhaps even a table
```{r}
#| label: tabl
#| tbl-cap: Summary of the cars data set
library(knitr)
kable(summary(cars), booktabs=TRUE)
`` `
In the example, note that although we had nominated for
kable output when printing dataframes, this does not by
default apply things like captions and booktabs formatting. Hence notice
in the above example that the first table (resulting from a call to
head) has not been fully formatted and does not have a
caption whereas the second table does have these features.
More wholesale style changes are supported by the use of templates.
Whilst pandoc comes with a default LaTeX template, it is
possible to create your own so as to provide even greater control over
the output style. To illustrate, we will create a very minimal pandoc
template for LaTeX (lets call it latex.template).
pandoc replaces specific tags (words enclosed in a pair
of $ signs) with particular items (such as the document
body or YAML options). In the following example, pandoc
will replace the $documentclass$ with whatever is specified
in the YAML header and $body$ with the markdown document
body.
latex.template
\documentclass{$documentclass$}
\usepackage{hyperref}
$if(highlighting-macros)$
$highlighting-macros$
$endif$
\begin{document}
$body$
\end{document}
Example7a.qmd
---
title: The title
format:
pdf:
latex_engine: xelatex
template: latex.template
highlight: none
documentclass: article
classoption: a4paper
mainfont: Arial
mathfont: LiberationMono
monofont: DejaVu Sans Mono
abstract: This is the abstract
urlcolor: red
---
Section
===========
Text with embedded R code.
```{r}
#| label: head
head(cars)
`` `
$$
y_i = \beta_0 + \beta_1 x_i
$$
In this way it is possible to construct a complete template so as to have full control over the output document style.
Writing LaTeX code, and thus LaTeX templates is not easy for those not familiar with the language. Fortunately there are numerous templates available, the most popular of which are:
The rticles package provides additional
Rmarkdown pandoc templates as well as wrapper functions to help put all
the template and associated files in the correct location. Furthermore,
if the rticles package is installed, then Rstudio
will have additional templates available from the new R markdown dialog
box.
The same can be completed in script using the draft
function from the rmarkdown package.
rmarkdown::draft(file='../resources/plos.Rmd', template='plos', package='rticles', edit=FALSE)
rmarkdown::render('../resources/plos/plos.Rmd')
rmarkdown::draft(file='../resources/pnas.Rmd', template='pnas', package='rticles', edit=FALSE)
rmarkdown::render('../resources/pnas/pnas.Rmd')
rmarkdown::draft(file='../resources/elsevier.Rmd', template='elsevier', package='rticles', edit=FALSE)
rmarkdown::render('../resources/elsevier/elsevier.Rmd')Unlike PDF and Word documents, HTML documents have the potential to be more interactive and dynamic. This allows the presentation of content to be more flexible. Consequently, there are numerous customizations that can be applied to HTML documents that cannot be applied to other document types.
There are a number of additional second-level YAML arguments that can be used to customize HTML documents - these are listed in the following table.
| Option | Description |
|---|---|
toc_float: true |
Float the table of contents in a panel on the side of the document. Other options are also available (see below) |
collapse: true |
Collapse the table of contents to just the first level headings |
smooth_scroll: true |
Animate page scrolling when items selected from table of contents |
self_contained: true |
Whether to generate a self contained (stand alone) HTML (other than Mathjax) |
One way to maintain present content in a compact manner without
excluding material is to have content that is hidden until it it
revealed. This behaviour is supported via tabsets. Tabsets are
defined by placing a .tabset class attribute. All
subheadings under this heading will then be rendered as tabs.
---
title: This is the title
author: D. Author
date: 14-02-2013
output:
bookdown::html_document2:
toc: yes
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
df_print: kable
highlight: zenburn
code_folding: hide
theme: spacelab
toc_float: yes
collapse: no
---
## Output {.tabset .tabset-fade}
### Figure
We can include a figure
```{r Plot, fig.cap='Gaussian density.',message=FALSE}
library(tidyverse)
data.frame(x=rnorm(1000)) %>%
ggplot(aes(x=x)) + geom_density()
`` `
### Table
```{r table}
library(knitr)
kable(summary(cars), caption='Summary of the cars data set')
`` `
To break a tabset, begin a new parent section. For example, in the
above example (in which a tabset is defined on the
## Output subsection), we could break the tabs (to allow
more content after the tabs) by starting a new blank subsection heading
(e.g. ##). To ensure that this blank or ghost section is
not included in the table of contents (or any heading formatting), we
can include {.unlisted .unnumbered}
attributes.
The general look and style of a HTML document is controlled via Cascading Style Sheet (CSS). A CSS comprises one or more files that define the styling of the HTML elements. Rmarkdown has a default HTML template and style sheet that are used by pandoc when converting markdown documents to HTML documents.
It is possible to provide alternate templates and CSS. For example,
to nominate an additional CSS that will be applied to the default
template after the default CSS file, we can use the css:
second-level argument. Since, this additional CSS is
applied after the default CSS, any styles defined within the additional
CSS will take precedence.
For a simple example, if we wanted all the Section headings to be a light blue color and the title to be the same colour blue colour as the dropdown menu background, we could define the following:
my-style.css
h1, h2, h3 {
color: lightblue;
}
h1.title {
color: #446e9b;
}
Example8b.Rmd
---
title: This is the title
author: D. Author
date: 14-02-2013
output:
bookdown::html_document2:
toc: yes
toc_depth: 2
number_sections: yes
fig_width: 5
fig_height: 5
df_print: kable
highlight: zenburn
code_folding: hide
theme: spacelab
toc_float: yes
collapse: no
css: my-style.css
---
# Section 1
Text with embedded R code.
```{r Summary}
mean(rnorm(10))
`` `
```{r head}
head(cars)
`` `
## Output {.tabset .tabset-fade}
### Figure
We can include a figure
```{r Plot, fig.cap='Gaussian density.',message=FALSE}
library(tidyverse)
data.frame(x=rnorm(1000)) %>%
ggplot(aes(x=x)) + geom_density()
`` `
### Table
```{r table}
library(knitr)
kable(summary(cars), caption='Summary of the cars data set')
`` `